// custom-tab-bar/index.js
import {storeBindingsBehavior} from 'mobx-miniprogram-bindings'
import {store} from '../store/store'
Component({
    /**
     * 组件的属性列表
     */
    behaviors:[storeBindingsBehavior],
    storeBindings: {
        store,
        fields: {
            active: 'activeTabBarIndex'
        },
        actions: {
            updateActive: 'updateActiveTabBarIndex'
        }
    },
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
    "list": [{
        "pagePath": "/pages/index/index",
        "text": "首页",
        "iconPath": "/image/首页.png",
        "selectedIconPath": "/image/首页选中.png"
    },
    {
      "pagePath": "/pages/message/message",
      "text": "消息",
      "iconPath": "/image/消息 .png",
      "selectedIconPath": "/image/消息选中.png"
  },
  {
      "pagePath": "/pages/user/user",
      "text": "用户",
      "iconPath": "/image/用户.png",
      "selectedIconPath": "/image/用户选中.png"
  }
  ]
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onChange(event) {
            // event.detail 的值为当前选中项的索引
            // this.setData({ active: event.detail });
            this.updateActive(event.detail)
            wx.switchTab({
                url: this.data.list[event.detail].pagePath,
              })
          }
    }
})
